< previous page page_749 next page >

Page 749
note.gif You can create a profile in the Mail and Fax Control Panel applet or from the Tools, Services menu in Outlook. square.gif

The third parameter, ShowDiag, is a boolean value which determines whether any dialog boxes should be shown during e-mail logon. If this parameter is set to True, the user will see the logon prompt even if you have provided all of the necessary parameters. For automatic, unattended logon, you need to set this property to False.
The final optional parameter, NewSession, determines whether a new session is created during the logon process even if one already exists. By setting this parameter to False, you can cause Active Messaging to share an existing e-mail session. In other words, if you already have Outlook open, then Active Messaging does not have to repeat the logon process.
Sending a Message
The great thing about Active Messaging is that messages and other objects are represented using the familiar collections syntax. We have already discussed collections in several other chapters, so you should be familiar with adding and removing objects in a collection. As with many other collections, the collection's Add method can be used to create objects in two ways: to return an object reference or with parameters specifying object properties.
sarrow.gifSee "Creating Classes That Contain Collections," p. 373
To send a message with Active Messaging, you need to perform the following steps:
1. Add a new Message object to the Messages collection of the Inbox.
2. Set the message text, subject, and add files to the Attachments collection.
3. Add the recipients' names (and/or addresses) to the Recipients collection.
4. Resolve recipients' names to determine their actual addresses.
5. Call the Send method to send the message.
The code to perform all of the preceding steps is both short and easy to understand:
'  . . . Assume we have already logged on 
  
    'Add a new message to the Inbox
    Set objMessage = objSession.Inbox.Messages.Add
    
    'Set the subject and body text
    objMessage.Subject = "Test Message"
    objMessage.Text = "This is a test, repeat only a test message!"
    
    'Add an attachment
    objMessage.Attachments.Add "Monthly Report", , ActMsgFileData, _ 
          "C:\MyReport.XLS"
        
    'Add a recipient to the list
    objMessage.Recipients.Add "bsiler@bigfoot.com", , ActMsgTo
    objMessage.Recipients.Resolve

 
< previous page page_749 next page >